diff --git a/objects/user.php b/objects/user.php
index acfd9c58e..0568ba385 100644
--- a/objects/user.php
+++ b/objects/user.php
@@ -1,1548 +1,1571 @@
user = $user;
if ($password !== false) {
$this->password = $password;
} else {
$this->loadFromUser($user);
}
} else {
// get data from id
$this->load($id);
}
}
function getEmail() {
return $this->email;
}
function getUser() {
return $this->user;
}
function getAbout() {
return str_replace(array('\\\\\\\n'), array("\n"), $this->about);
}
function setAbout($about) {
$this->about = xss_esc($about);
}
function getPassword() {
return $this->password;
}
function getCanStream() {
return $this->canStream;
}
function setCanStream($canStream) {
$this->canStream = (empty($canStream) || strtolower($canStream) === 'false') ? 0 : 1;
}
function getCanViewChart() {
return $this->canViewChart;
}
function setCanViewChart($canViewChart) {
$this->canViewChart = (empty($canViewChart) || strtolower($canViewChart) === 'false') ? 0 : 1;
}
function getCanUpload() {
return $this->canUpload;
}
function setCanUpload($canUpload) {
$this->canUpload = (empty($canUpload) || strtolower($canUpload) === 'false') ? 0 : 1;
}
function getAnalyticsCode() {
return $this->analyticsCode;
}
function setAnalyticsCode($analyticsCode) {
preg_match("/(ua-\d{4,9}-\d{1,4})/i", $analyticsCode, $matches);
if (!empty($matches[1])) {
$this->analyticsCode = $matches[1];
} else {
$this->analyticsCode = "";
}
}
function getAnalytics() {
$id = $this->getId();
$aCode = $this->getAnalyticsCode();
if (!empty($id) && !empty($aCode)) {
$code = "
";
} else {
$code = "";
}
return $code;
}
function addExternalOptions($id, $value) {
$eo = unserialize(base64_decode($this->externalOptions));
if (!is_array($eo)) {
$eo = array();
}
$eo[$id] = $value;
$this->setExternalOptions($eo);
return $this->save();
}
function removeExternalOptions($id) {
$eo = unserialize(base64_decode($this->externalOptions));
unset($eo[$id]);
$this->setExternalOptions($eo);
return $this->save();
}
function setExternalOptions($options) {
//we convert it to base64 to sanitize the input since we do not validate input from externalOptions
$this->externalOptions = base64_encode(serialize($options));
}
function getExternalOption($id) {
$eo = unserialize(base64_decode($this->externalOptions));
if (empty($eo[$id])) {
return NULL;
}
return $eo[$id];
}
private function load($id) {
$user = self::getUserDb($id);
if (empty($user))
return false;
foreach ($user as $key => $value) {
$this->$key = $value;
}
return true;
}
private function loadFromUser($user) {
$user = self::getUserDbFromUser($user);
if (empty($user))
return false;
foreach ($user as $key => $value) {
$this->$key = $value;
}
return true;
}
function loadSelfUser() {
$this->load($this->getId());
}
static function getId() {
if (self::isLogged()) {
return $_SESSION['user']['id'];
} else {
return false;
}
}
static function getEmail_() {
if (self::isLogged()) {
return $_SESSION['user']['email'];
} else {
return false;
}
}
function getBdId() {
return $this->id;
}
static function updateSessionInfo() {
if (self::isLogged()) {
$user = self::getUserDb($_SESSION['user']['id']);
$_SESSION['user'] = $user;
}
}
static function getName() {
if (self::isLogged()) {
return $_SESSION['user']['name'];
} else {
return false;
}
}
static function getUserName() {
if (self::isLogged()) {
return $_SESSION['user']['user'];
} else {
return false;
}
}
static function getUserChannelName() {
if (self::isLogged()) {
if (empty($_SESSION['user']['channelName'])) {
$_SESSION['user']['channelName'] = uniqid();
$user = new User(User::getId());
$user->setChannelName($_SESSION['user']['channelName']);
$user->save();
}
return $_SESSION['user']['channelName'];
} else {
return false;
}
}
/**
* return an name to identify the user
* @return String
*/
static function getNameIdentification() {
global $advancedCustomUser;
if (self::isLogged()) {
if (!empty(self::getName()) && empty($advancedCustomUser->doNotIndentifyByName)) {
return self::getName();
}
if (!empty(self::getMail()) && empty($advancedCustomUser->doNotIndentifyByEmail)) {
return self::getMail();
}
if (!empty(self::getUserName()) && empty($advancedCustomUser->doNotIndentifyByUserName)) {
return self::getUserName();
}
if (!empty(self::getUserChannelName())) {
return self::getUserChannelName();
}
}
return __("Unknown User");
}
/**
* return an name to identify the user from database
* @return String
*/
function getNameIdentificationBd() {
global $advancedCustomUser;
if (!empty($this->name) && empty($advancedCustomUser->doNotIndentifyByName)) {
return $this->name;
}
if (!empty($this->email) && empty($advancedCustomUser->doNotIndentifyByEmail)) {
return $this->email;
}
if (!empty($this->user) && empty($advancedCustomUser->doNotIndentifyByUserName)) {
return $this->user;
}
if (!empty($this->channelName)) {
return $this->channelName;
}
return __("Unknown User");
}
static function getNameIdentificationById($id = "") {
if (!empty($id)) {
$user = new User($id);
return $user->getNameIdentificationBd();
}
return __("Unknown User");
}
static function getUserPass() {
if (self::isLogged()) {
return $_SESSION['user']['password'];
} else {
return false;
}
}
function _getName() {
return $this->name;
}
static function getPhoto($id = "") {
global $global;
if (!empty($id)) {
$user = self::findById($id);
if (!empty($user)) {
$photo = $user['photoURL'];
}
} elseif (self::isLogged()) {
$photo = $_SESSION['user']['photoURL'];
}
if (!empty($photo) && preg_match("/videos\/userPhoto\/.*/", $photo)) {
if (file_exists($global['systemRootPath'] . $photo)) {
$photo = $global['webSiteRootURL'] . $photo;
} else {
$photo = "";
}
}
if (empty($photo)) {
$photo = $global['webSiteRootURL'] . "view/img/userSilhouette.jpg";
}
return $photo;
}
+
+ static function getEmailVerifiedIcon($id = "") {
+ global $advancedCustomUser;
+ if(empty($advancedCustomUser->showEmailVerifiedMark)){
+ return '';
+ }
+ if (!empty($id)) {
+ $user = self::findById($id);
+ if (!empty($user)) {
+ $verified = $user['emailVerified'];
+ }
+ } elseif (self::isLogged()) {
+ $verified = $_SESSION['user']['emailVerified'];
+ }
+ if(!isset($verified)){
+ return "";
+ }
+ if(!empty($verified)){
+ return ' ';
+ }else{
+ return ' ';
+ }
+ }
function getPhotoDB() {
return self::getPhoto($this->id);
}
static function getBackground($id = "") {
global $global;
if (!empty($id)) {
$user = self::findById($id);
if (!empty($user)) {
$photo = $user['backgroundURL'];
}
} elseif (self::isLogged()) {
$photo = $_SESSION['user']['backgroundURL'];
}
if (!empty($photo) && preg_match("/videos\/userPhoto\/.*/", $photo)) {
if (file_exists($global['systemRootPath'] . $photo)) {
$photo = $global['webSiteRootURL'] . $photo;
} else {
$photo = "";
}
}
if (empty($photo)) {
$photo = $global['webSiteRootURL'] . "view/img/background.png";
}
return $photo;
}
static function getMail() {
if (self::isLogged()) {
return $_SESSION['user']['email'];
} else {
return false;
}
}
function save($updateUserGroups = false) {
global $global, $config, $advancedCustom, $advancedCustomUser;
if (is_object($config) && $config->currentVersionLowerThen('5.6')) {
// they dont have analytics code
return false;
}
if (empty($this->user) || empty($this->password)) {
//echo "u:" . $this->user . "|p:" . strlen($this->password);
error_log('Error : ' . __("You need a user and passsword to register"));
return false;
}
if (empty($this->isAdmin)) {
$this->isAdmin = "false";
}
if (empty($this->canStream)) {
if (empty($this->id)) { // it is a new user
if (empty($advancedCustomUser->newUsersCanStream)) {
$this->canStream = "0";
} else {
$this->canStream = "1";
}
} else {
$this->canStream = "0";
}
}
if (empty($this->canUpload)) {
$this->canUpload = "0";
}
if (empty($this->status)) {
$this->status = 'a';
}
if (empty($this->emailVerified))
$this->emailVerified = "false";
if (empty($this->channelName)) {
$this->channelName = uniqid();
} else {
$channelOwner = static::getChannelOwner($this->channelName);
if (!empty($channelOwner)) { // if the channel name exists and it is not from this user, rename the channel name
if (empty($this->id) || $channelOwner['id'] != $this->id) {
$this->channelName .= uniqid();
}
}
}
$this->user = $global['mysqli']->real_escape_string($this->user);
$this->password = $global['mysqli']->real_escape_string($this->password);
$this->name = $global['mysqli']->real_escape_string($this->name);
$this->status = $global['mysqli']->real_escape_string($this->status);
$this->about = $global['mysqli']->real_escape_string($this->about);
$this->about = preg_replace("/(\\\)+n/", "\n", $this->about);
$this->channelName = $global['mysqli']->real_escape_string($this->channelName);
if (empty($this->channelName)) {
$this->channelName = uniqid();
}
if (filter_var($this->donationLink, FILTER_VALIDATE_URL) === FALSE) {
$this->donationLink = "";
}
if (!empty($this->id)) {
$formats = "ssssiii";
$values = array($this->user, $this->password, $this->email, $this->name, $this->isAdmin, $this->canStream, $this->canUpload);
$sql = "UPDATE users SET user = ?, password = ?, "
. "email = ?, name = ?, isAdmin = ?,"
. "canStream = ?,canUpload = ?,";
if (isset($this->canViewChart)) {
$formats .= "i";
$values[] = $this->canViewChart;
$sql .= "canViewChart = ?, ";
}
$formats .= "ssssssissssssssssi";
$values[] = $this->status;
$values[] = $this->photoURL;
$values[] = $this->backgroundURL;
$values[] = $this->recoverPass;
$values[] = $this->about;
$values[] = $this->channelName;
$values[] = $this->emailVerified;
$values[] = $this->analyticsCode;
$values[] = $this->externalOptions;
$values[] = $this->first_name;
$values[] = $this->last_name;
$values[] = $this->address;
$values[] = $this->zip_code;
$values[] = $this->country;
$values[] = $this->region;
$values[] = $this->city;
$values[] = $this->donationLink;
$values[] = $this->id;
$sql .= "status = ?, "
. "photoURL = ?, backgroundURL = ?, "
. "recoverPass = ?, about = ?, "
. " channelName = ?, emailVerified = ? , analyticsCode = ?, externalOptions = ? , "
. " first_name = ? , last_name = ? , address = ? , zip_code = ? , country = ? , region = ? , city = ? , donationLink = ? , "
. " modified = now() WHERE id = ?";
} else {
$formats = "ssssiiissssss";
$values = array($this->user, $this->password, $this->email, $this->name, $this->isAdmin, $this->canStream, $this->canUpload,
$this->status, $this->photoURL, $this->recoverPass, $this->channelName, $this->analyticsCode, $this->externalOptions);
$sql = "INSERT INTO users (user, password, email, name, isAdmin, canStream, canUpload, canViewChart, status,photoURL,recoverPass, created, modified, channelName, analyticsCode, externalOptions) "
. " VALUES (?,?,?,?,?,?,?, false, "
. "?,?,?, now(), now(),?,?,?)";
}
$insert_row = sqlDAL::writeSql($sql, $formats, $values);
if ($insert_row) {
if (empty($this->id)) {
$id = $global['mysqli']->insert_id;
if (!empty($advancedCustomUser->unverifiedEmailsCanNOTLogin)) {
self::sendVerificationLink($id);
}
} else {
$id = $this->id;
}
if ($updateUserGroups) {
require_once $global['systemRootPath'] . 'objects/userGroups.php';
// update the user groups
UserGroups::updateUserGroups($id, $this->userGroups);
}
return $id;
} else {
error_log(' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error . " $sql");
return false;
}
}
static function getChannelOwner($channelName) {
global $global;
$channelName = $global['mysqli']->real_escape_string($channelName);
$sql = "SELECT * FROM users WHERE channelName = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($channelName));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$user = $result;
} else {
$user = false;
}
return $user;
}
static function getFromUsername($user) {
global $global;
$user = $global['mysqli']->real_escape_string($user);
$sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($user));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$user = $result;
} else {
$user = false;
}
return $user;
}
static function canWatchVideo($videos_id) {
if (User::isAdmin()) {
return true;
}
if (YouPHPTubePlugin::userCanWatchVideo(User::getId(), $videos_id)) {
return true;
}
// check if the video is not public
$rows = UserGroups::getVideoGroups($videos_id);
if (empty($rows)) {
// check if any plugin restrict access to this video
if (!YouPHPTubePlugin::userCanWatchVideo(User::getId(), $videos_id)) {
return false;
} else {
return true; // the video is public
}
}
if (!User::isLogged()) {
return false;
}
// if is not public check if the user is on one of its groups
$rowsUser = UserGroups::getUserGroups(User::getId());
foreach ($rows as $value) {
foreach ($rowsUser as $value2) {
if ($value['id'] === $value2['id']) {
return true;
}
}
}
return false;
}
static function canWatchVideoWithAds($videos_id) {
if (YouPHPTubePlugin::userCanWatchVideoWithAds(User::getId(), $videos_id) || self::canWatchVideo($videos_id)) {
return true;
}
return false;
}
function delete() {
if (!self::isAdmin()) {
return false;
}
// cannot delete yourself
if (self::getId() === $this->id) {
return false;
}
global $global;
if (!empty($this->id)) {
$sql = "DELETE FROM users WHERE id = ?";
} else {
return false;
}
return sqlDAL::writeSql($sql, "i", array($this->id));
}
const USER_LOGGED = 0;
const USER_NOT_VERIFIED = 1;
const USER_NOT_FOUND = 2;
const CAPTCHA_ERROR = 3;
function login($noPass = false, $encodedPass = false) {
global $global, $advancedCustom, $advancedCustomUser, $config;
if (strtolower($encodedPass) === 'false') {
$encodedPass = false;
}
error_log("user::login: noPass = $noPass, encodedPass = $encodedPass, this->user, $this->user " . getRealIpAddr());
if ($noPass) {
$user = $this->find($this->user, false, true);
} else {
$user = $this->find($this->user, $this->password, true, $encodedPass);
}
if (!self::checkLoginAttempts()) {
return self::CAPTCHA_ERROR;
}
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// check for multiple logins attempts to prevent hacking end
// if user is not verified
if (!empty($user) && empty($user['isAdmin']) && empty($user['emailVerified']) && !empty($advancedCustomUser->unverifiedEmailsCanNOTLogin)) {
unset($_SESSION['user']);
self::sendVerificationLink($user['id']);
return self::USER_NOT_VERIFIED;
} else if ($user) {
$_SESSION['user'] = $user;
$this->setLastLogin($_SESSION['user']['id']);
$rememberme = 0;
if ((!empty($_POST['rememberme']) && $_POST['rememberme'] == "true") || !empty($_COOKIE['rememberme'])) {
error_log("user::login: Do login with cookie (log in for next 10 years)!");
//$url = parse_url($global['webSiteRootURL']);
//setcookie("user", $this->user, time()+3600*24*30*12*10,$url['path'],$url['host']);
//setcookie("pass", $encodedPass, time()+3600*24*30*12*10,$url['path'],$url['host']);
$cookie = 2147483647;
$rememberme = 1;
} else {
error_log("user::login: Do login without cookie");
if (empty($config) || !is_object($config)) {
$config = new Configuration();
}
$cookie = $config->getSession_timeout();
}
if (empty($_COOKIE['user']) || empty(empty($_COOKIE['pass']))) {
if (empty($cookie)) {
$cookie = 86400; // 24 hours
}
setcookie("rememberme", $rememberme, $cookie, "/", $_SERVER['HTTP_HOST']);
setcookie("user", $user['user'], $cookie, "/", $_SERVER['HTTP_HOST']);
setcookie("pass", $user['password'], $cookie, "/", $_SERVER['HTTP_HOST']);
}
YouPHPTubePlugin::onUserSignIn($_SESSION['user']['id']);
$_SESSION['loginAttempts'] = 0;
return self::USER_LOGGED;
} else {
unset($_SESSION['user']);
return self::USER_NOT_FOUND;
}
}
static function isCaptchaNeed() {
global $advancedCustomUser;
// check for multiple logins attempts to prevent hacking
if (!empty($_SESSION['loginAttempts']) && !empty($advancedCustomUser->requestCaptchaAfterLoginsAttempts)) {
if ($_SESSION['loginAttempts'] > $advancedCustomUser->requestCaptchaAfterLoginsAttempts) {
return true;
}
}
return false;
}
static function checkLoginAttempts() {
global $advancedCustomUser, $global;
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// check for multiple logins attempts to prevent hacking
if (empty($_SESSION['loginAttempts'])) {
$_SESSION['loginAttempts'] = 0;
}
if (!empty($advancedCustomUser->requestCaptchaAfterLoginsAttempts)) {
$_SESSION['loginAttempts'] ++;
session_write_close();
if ($_SESSION['loginAttempts'] > $advancedCustomUser->requestCaptchaAfterLoginsAttempts) {
if (empty($_POST['captcha'])) {
return false;
}
require_once $global['systemRootPath'] . 'objects/captcha.php';
if (!Captcha::validation($_POST['captcha'])) {
return false;
}
}
}
session_write_close();
return true;
}
static function getCaptchaFormIfNeed() {
// check for multiple logins attempts to prevent hacking
if (self::isCaptchaNeed()) {
return self::getCaptchaForm();
}
return "";
}
static function getCaptchaForm($uid = "") {
global $global;
return '
';
}
private function setLastLogin($user_id) {
global $global;
if (empty($user_id)) {
die('Error : setLastLogin ');
}
$sql = "UPDATE users SET lastLogin = now(), modified = now() WHERE id = ?";
return sqlDAL::writeSql($sql, "i", array($user_id));
}
static function logoff() {
global $global;
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
//$url = parse_url($global['webSiteRootURL']);
unset($_COOKIE['rememberme']);
unset($_COOKIE['user']);
unset($_COOKIE['pass']);
// setcookie('user', null, -1,$url['path'],$url['host']);
// setcookie('pass', null, -1,$url['path'],$url['host']);
setcookie('rememberme', null, -1, "/", $_SERVER['HTTP_HOST']);
setcookie('user', null, -1, "/", $_SERVER['HTTP_HOST']);
setcookie('pass', null, -1, "/", $_SERVER['HTTP_HOST']);
setcookie('rememberme', null, -1, "/");
setcookie('user', null, -1, "/");
setcookie('pass', null, -1, "/");
unset($_SESSION['user']);
}
static private function recreateLoginFromCookie() {
if (empty($_SESSION['user'])) {
if ((!empty($_COOKIE['user'])) && (!empty($_COOKIE['pass']))) {
$user = new User(0, $_COOKIE['user'], false);
$user->setPassword($_COOKIE['pass'], true);
// $dbuser = self::getUserDbFromUser($_COOKIE['user']);
$resp = $user->login(false, true);
error_log("user::recreateLoginFromCookie: do cookie-login: " . $_COOKIE['user'] . " result: " . $resp);
if (0 == $resp) {
error_log("success " . $_SESSION['user']['id']);
} else {
error_log("user::recreateLoginFromCookie: do logoff: " . $_COOKIE['user'] . " result: " . $resp);
self::logoff();
}
}
}
}
static function isLogged() {
self::recreateLoginFromCookie();
return !empty($_SESSION['user']['id']);
}
static function isVerified() {
self::recreateLoginFromCookie();
return !empty($_SESSION['user']['emailVerified']);
}
static function isAdmin() {
self::recreateLoginFromCookie();
return !empty($_SESSION['user']['isAdmin']);
}
static function canStream() {
self::recreateLoginFromCookie();
return !empty($_SESSION['user']['isAdmin']) || !empty($_SESSION['user']['canStream']);
}
static function externalOptions($id) {
if (!empty($_SESSION['user']['externalOptions'])) {
$externalOptions = unserialize(base64_decode($_SESSION['user']['externalOptions']));
if (isset($externalOptions[$id])) {
if ($externalOptions[$id] == "true")
$externalOptions[$id] = true;
else
if ($externalOptions[$id] == "false")
$externalOptions[$id] = false;
return $externalOptions[$id];
}
}
return false;
}
function thisUserCanStream() {
if ($this->status === 'i') {
return false;
}
return !empty($this->isAdmin) || !empty($this->canStream);
}
private function find($user, $pass, $mustBeactive = false, $encodedPass = false) {
global $global, $advancedCustom;
$formats = "";
$values = array();
$user = $global['mysqli']->real_escape_string($user);
$sql = "SELECT * FROM users WHERE user = ? ";
$formats .= "s";
$values[] = $user;
if ($mustBeactive) {
$sql .= " AND status = 'a' ";
}
$sql .= " LIMIT 1";
$res = sqlDAL::readSql($sql, $formats, $values, true);
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if (!empty($result)) {
if ($pass !== false) {
if (!encryptPasswordVerify($pass, $result['password'], $encodedPass)) {
if ($advancedCustom->enableOldPassHashCheck) {
error_log("Password check new hash pass does not match, trying MD5");
return $this->find_Old($user, $pass, $mustBeactive, $encodedPass);
} else {
return false;
}
}
}
$user = $result;
} else {
error_log("Password check new hash user not found");
//check if is the old password style
$user = false;
//$user = false;
}
return $user;
}
/**
* this is the deprecated function, with week password
* @global type $global
* @param type $user
* @param type $pass
* @param type $mustBeactive
* @param type $encodedPass
* @return boolean
*/
private function find_Old($user, $pass, $mustBeactive = false, $encodedPass = false) {
global $global;
$formats = "";
$values = array();
$user = $global['mysqli']->real_escape_string($user);
$sql = "SELECT * FROM users WHERE user = ? ";
$formats .= "s";
$values[] = $user;
if ($mustBeactive) {
$sql .= " AND status = 'a' ";
}
if ($pass !== false) {
if (!$encodedPass || $encodedPass === 'false') {
error_log("Password check Old not encoded pass");
$passEncoded = md5($pass);
} else {
error_log("Password check Old encoded pass");
$passEncoded = $pass;
}
$sql .= " AND password = ? ";
$formats .= "s";
$values[] = $passEncoded;
}
$sql .= " LIMIT 1";
$res = sqlDAL::readSql($sql, $formats, $values, true);
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if (!empty($result)) {
if (!$encodedPass || $encodedPass === 'false') {
//update the password
$u = new User($result['id']);
$u->setPassword($pass);
$u->save();
$result['password'] = $u->getPassword();
}
$user = $result;
} else {
$user = false;
}
if (empty($user)) {
error_log("Password check Old not found");
} else {
error_log("Password check Old found");
}
return $user;
}
static private function findById($id) {
global $global;
$id = intval($id);
if (empty($id)) {
return false;
}
$sql = "SELECT * FROM users WHERE id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "i", array($id));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$user = $result;
} else {
$user = false;
}
return $user;
}
static function findByEmail($email) {
global $global;
$email = trim($email);
if (empty($email)) {
return false;
}
$sql = "SELECT * FROM users WHERE email = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($email));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res != false) {
$user = $result;
} else {
$user = false;
}
return $user;
}
static private function getUserDb($id) {
global $global;
$id = intval($id);
if (empty($id)) {
return false;
}
$sql = "SELECT * FROM users WHERE id = ? LIMIT 1;";
$res = sqlDAL::readSql($sql, "i", array($id));
$user = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($user != false) {
return $user;
}
return false;
}
static private function getUserDbFromUser($user) {
global $global;
if (empty($user)) {
return false;
}
$sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($user));
$user = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($user != false) {
return $user;
}
return false;
}
function setUser($user) {
global $advancedCustomUser;
if (empty($advancedCustomUser->userCanChangeUsername)) {
if (!empty($this->user)) {
return false;
}
}
$this->user = strip_tags($user);
}
function setName($name) {
$this->name = strip_tags($name);
}
function setEmail($email) {
$this->email = strip_tags($email);
}
function setPassword($password, $doNotEncrypt = false) {
if (!empty($password)) {
if ($doNotEncrypt) {
$this->password = ($password);
} else {
$this->password = encryptPassword($password);
}
}
}
function setIsAdmin($isAdmin) {
if (empty($isAdmin) || $isAdmin === "false" || !User::isAdmin()) {
$isAdmin = "0";
} else {
$isAdmin = "1";
}
$this->isAdmin = $isAdmin;
}
function setStatus($status) {
$this->status = strip_tags($status);
}
function getPhotoURL() {
return $this->photoURL;
}
function setPhotoURL($photoURL) {
$this->photoURL = strip_tags($photoURL);
}
static function getAllUsers($ignoreAdmin = false, $searchFields = array('name', 'email', 'user', 'channelName', 'about')) {
if (!self::isAdmin() && !$ignoreAdmin) {
return false;
}
//will receive
//current=1&rowCount=10&sort[sender]=asc&searchPhrase=
global $global;
$sql = "SELECT * FROM users WHERE 1=1 ";
$sql .= BootGrid::getSqlFromPost($searchFields);
$user = array();
require_once $global['systemRootPath'] . 'objects/userGroups.php';
$res = sqlDAL::readSql($sql . ";");
$downloadedArray = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
if ($res != false) {
foreach ($downloadedArray as $row) {
$row['groups'] = UserGroups::getUserGroups($row['id']);
$row['identification'] = self::getNameIdentificationById($row['id']);
$row['photo'] = self::getPhoto($row['id']);
$row['background'] = self::getBackground($row['id']);
$row['tags'] = self::getTags($row['id']);
$row['name'] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $row['name']);
$row['isEmailVerified'] = $row['emailVerified'];
if (!is_null($row['externalOptions'])) {
$externalOptions = unserialize(base64_decode($row['externalOptions']));
if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
foreach ($externalOptions as $k => $v) {
if ($v == "true")
$v = 1;
else
if ($v == "false")
$v = 0;
$row[$k] = $v;
}
}
}
unset($row['password']);
unset($row['recoverPass']);
if (!User::isAdmin() && $row['id'] !== User::getId()) {
unset($row['first_name']);
unset($row['last_name']);
unset($row['address']);
unset($row['zip_code']);
unset($row['country']);
unset($row['region']);
unset($row['city']);
}
$user[] = $row;
}
} else {
$user = false;
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $user;
}
static function getTotalUsers($ignoreAdmin = false) {
if (!self::isAdmin() && !$ignoreAdmin) {
return false;
}
//will receive
//current=1&rowCount=10&sort[sender]=asc&searchPhrase=
global $global;
$sql = "SELECT id FROM users WHERE 1=1 ";
$sql .= BootGrid::getSqlSearchFromPost(array('name', 'email', 'user'));
$res = sqlDAL::readSql($sql);
$result = sqlDal::num_rows($res);
sqlDAL::close($res);
return $result;
}
static function userExists($user) {
global $global;
$user = $global['mysqli']->real_escape_string($user);
$sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($user));
$user = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($user != false) {
return $user['id'];
} else {
return false;
}
}
static function idExists($users_id) {
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM users WHERE id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "i", array($users_id));
$user = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($user != false) {
return $user['id'];
} else {
return false;
}
}
static function createUserIfNotExists($user, $pass, $name, $email, $photoURL, $isAdmin = false, $emailVerified = false) {
global $global;
$user = $global['mysqli']->real_escape_string($user);
if (!$userId = self::userExists($user)) {
if (empty($pass)) {
$pass = uniqid();
}
$pass = encryptPassword($pass);
$userObject = new User(0, $user, $pass);
$userObject->setEmail($email);
$userObject->setName($name);
$userObject->setIsAdmin($isAdmin);
$userObject->setPhotoURL($photoURL);
$userObject->setEmailVerified($emailVerified);
$userId = $userObject->save();
return $userId;
}
return $userId;
}
function getRecoverPass() {
return $this->recoverPass;
}
function setRecoverPass($recoverPass) {
$this->recoverPass = $recoverPass;
}
static function canUpload() {
global $global, $config;
if (User::isAdmin()) {
return true;
}
if ($config->getAuthCanUploadVideos()) {
return self::isLogged();
}
if (self::isLogged() && !empty($_SESSION['user']['canUpload'])) {
return true;
}
return self::isAdmin();
}
static function canViewChart() {
global $global, $config;
if (self::isLogged() && !empty($_SESSION['user']['canViewChart'])) {
return true;
}
return self::isAdmin();
}
static function canComment() {
global $global, $config;
if ($config->getAuthCanComment()) {
return self::isLogged();
}
return self::isAdmin();
}
static function canSeeCommentTextarea() {
global $global, $config;
if (!$config->getAuthCanComment()) {
if (!self::isAdmin()) {
return false;
}
}
return true;
}
function getUserGroups() {
return $this->userGroups;
}
function setUserGroups($userGroups) {
if (is_array($userGroups)) {
$this->userGroups = $userGroups;
}
}
function getIsAdmin() {
return $this->isAdmin;
}
function getStatus() {
return $this->status;
}
/**
*
* @param type $user_id
* text
* label Default Primary Success Info Warning Danger
*/
static function getTags($user_id) {
$user = new User($user_id);
$tags = array();
if ($user->getIsAdmin()) {
$obj = new stdClass();
$obj->type = "info";
$obj->text = __("Admin");
$tags[] = $obj;
} else {
$obj = new stdClass();
$obj->type = "default";
$obj->text = __("Regular User");
$tags[] = $obj;
}
if ($user->getStatus() == "a") {
$obj = new stdClass();
$obj->type = "success";
$obj->text = __("Active");
$tags[] = $obj;
} else {
$obj = new stdClass();
$obj->type = "danger";
$obj->text = __("Inactive");
$tags[] = $obj;
}
if ($user->getEmailVerified()) {
$obj = new stdClass();
$obj->type = "success";
$obj->text = __("E-mail Verified");
$tags[] = $obj;
} else {
$obj = new stdClass();
$obj->type = "warning";
$obj->text = __("E-mail Not Verified");
$tags[] = $obj;
}
global $global;
if (!empty($global['systemRootPath'])) {
require_once $global['systemRootPath'] . 'objects/userGroups.php';
} else {
require_once 'userGroups.php';
}
$groups = UserGroups::getUserGroups($user_id);
foreach ($groups as $value) {
$obj = new stdClass();
$obj->type = "warning";
$obj->text = $value['group_name'];
$tags[] = $obj;
}
return $tags;
}
function getBackgroundURL() {
if (empty($this->backgroundURL)) {
$this->backgroundURL = "view/img/background.png";
}
return $this->backgroundURL;
}
function setBackgroundURL($backgroundURL) {
$this->backgroundURL = strip_tags($backgroundURL);
}
function getChannelName() {
if (empty($this->channelName)) {
$this->channelName = uniqid();
$this->save();
}
return $this->channelName;
}
function getEmailVerified() {
return $this->emailVerified;
}
/**
*
* @param type $channelName
* @return boolean return true is is unique
*/
function setChannelName($channelName) {
$channelName = trim(preg_replace("/[^0-9A-Z_ -]/i", "", $channelName));
$user = static::getChannelOwner($channelName);
if (!empty($user)) { // if the channel name exists and it is not from this user, rename the channel name
if (empty($this->id) || $user['id'] != $this->id) {
return false;
}
}
$this->channelName = xss_esc($channelName);
return true;
}
function setEmailVerified($emailVerified) {
$this->emailVerified = (empty($emailVerified) || strtolower($emailVerified) === 'false') ? 0 : 1;
}
static function getChannelLink($users_id = 0) {
global $global, $config;
if ($config->currentVersionLowerThen('5.3')) {
return "{$global['webSiteRootURL']}channel/UpDateYourVersion";
}
if (empty($users_id)) {
$users_id = self::getId();
}
$user = new User($users_id);
if (empty($user)) {
return false;
}
if (empty($user->getChannelName())) {
$name = $user->getBdId();
} else {
$name = $user->getChannelName();
}
$link = "{$global['webSiteRootURL']}channel/" . urlencode($name);
return $link;
}
static function sendVerificationLink($users_id) {
global $global;
$config = new Configuration();
$user = new User($users_id);
$code = urlencode(static::createVerificationCode($users_id));
require_once $global['systemRootPath'] . 'objects/PHPMailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
if (!is_object($config)) {
error_log("sendVerificationLink: config is not a object " . json_encode($config));
return false;
}
$contactEmail = $config->getContactEmail();
$webSiteTitle = $config->getWebSiteTitle();
$email = $user->getEmail();
try {
$mail = new PHPMailer;
setSiteSendMessage($mail);
//$mail->SMTPDebug = 4;
//Set who the message is to be sent from
$mail->setFrom($contactEmail, $webSiteTitle);
//Set who the message is to be sent to
$mail->addAddress($email);
//Set the subject line
$mail->Subject = __('Please Verify Your E-mail ') . $webSiteTitle;
$msg = sprintf(__("Hi %s"), $user->getNameIdentificationBd());
$msg .= " " . __("Just a quick note to say a big welcome and an even bigger thank you for registering.");
$msg .= " " . sprintf(__("Cheers, %s Team."), $webSiteTitle);
$msg .= " " . sprintf(__("You are just one click away from starting your journey with %s!"), $webSiteTitle);
$msg .= " " . sprintf(__("All you need to do is to verify your e-mail by clicking the link below"));
$msg .= " " . " " . __("Verify") . " ";
$mail->msgHTML($msg);
$resp = $mail->send();
if (!$resp) {
error_log("sendVerificationLink Error Info: {$mail->ErrorInfo}");
}
return $resp;
} catch (phpmailerException $e) {
error_log($e->errorMessage()); //Pretty error messages from PHPMailer
} catch (Exception $e) {
error_log($e->getMessage()); //Boring error messages from anything else!
}
return false;
}
static function verifyCode($code) {
global $global;
$obj = static::decodeVerificationCode($code);
$salt = hash('sha256', $global['salt']);
if ($salt !== $obj->salt) {
return false;
}
$user = new User($obj->users_id);
$recoverPass = $user->getRecoverPass();
if ($recoverPass == $obj->recoverPass) {
$user->setEmailVerified(1);
return $user->save();
}
return false;
}
static function createVerificationCode($users_id) {
global $global;
$obj = new stdClass();
$obj->users_id = $users_id;
$obj->recoverPass = uniqid();
$obj->salt = hash('sha256', $global['salt']);
$user = new User($users_id);
$user->setRecoverPass($obj->recoverPass);
$user->save();
return base64_encode(json_encode($obj));
}
static function decodeVerificationCode($code) {
$obj = json_decode(base64_decode($code));
return $obj;
}
function getFirst_name() {
return $this->first_name;
}
function getLast_name() {
return $this->last_name;
}
function getAddress() {
return $this->address;
}
function getZip_code() {
return $this->zip_code;
}
function getCountry() {
return $this->country;
}
function getRegion() {
return $this->region;
}
function getCity() {
return $this->city;
}
function setFirst_name($first_name) {
$this->first_name = $first_name;
}
function setLast_name($last_name) {
$this->last_name = $last_name;
}
function setAddress($address) {
$this->address = $address;
}
function setZip_code($zip_code) {
$this->zip_code = $zip_code;
}
function setCountry($country) {
$this->country = $country;
}
function setRegion($region) {
$this->region = $region;
}
function setCity($city) {
$this->city = $city;
}
static function getDocumentImage($users_id) {
$row = static::getBlob($users_id, User::$DOCUMENT_IMAGE_TYPE);
if (!empty($row['blob'])) {
return $row['blob'];
}
return false;
}
static function saveDocumentImage($image, $users_id) {
$row = static::saveBlob($image, $users_id, User::$DOCUMENT_IMAGE_TYPE);
if (!empty($row['blob'])) {
return $row['blob'];
}
return false;
}
static function getBlob($users_id, $type) {
global $global;
$sql = "SELECT * FROM users_blob WHERE users_id = ? AND `type` = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "is", array($users_id, $type));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
return $result;
}
static function saveBlob($blob, $users_id, $type) {
global $global;
$row = self::getBlob($users_id, $type);
$null = NULL;
if (!empty($row['id'])) {
$sql = "UPDATE users_blob SET `blob` = ? , modified = now() WHERE id = ?";
$stmt = $global['mysqli']->prepare($sql);
$stmt->bind_param('bi', $null, $row['id']);
} else {
$sql = "INSERT INTO users_blob (`blob`, users_id, `type`, modified, created) VALUES (?,?,?, now(), now())";
$stmt = $global['mysqli']->prepare($sql);
$stmt->bind_param('bis', $null, $users_id, $type);
}
$stmt->send_long_data(0, $blob);
return $stmt->execute();
}
static function deleteBlob($users_id, $type) {
global $global;
$row = self::getBlob($users_id, $type);
if (!empty($row['id'])) {
$sql = "DELETE FROM users_blob ";
$sql .= " WHERE id = ?";
$global['lastQuery'] = $sql;
//error_log("Delete Query: ".$sql);
return sqlDAL::writeSql($sql, "i", array($row['id']));
}
error_log("Id for table users_blob not defined for deletion");
return false;
}
function getDonationLink() {
return $this->donationLink;
}
function getDonationLinkIfEnabled() {
global $advancedCustomUser;
if ($advancedCustomUser->allowDonationLink) {
return $this->donationLink;
}
return false;
}
function setDonationLink($donationLink) {
$this->donationLink = $donationLink;
}
}
diff --git a/objects/videos.json.php b/objects/videos.json.php
index acc4ff088..35f854ab5 100644
--- a/objects/videos.json.php
+++ b/objects/videos.json.php
@@ -1,53 +1,53 @@
$value) {
unset($value['password']);
unset($value['recoverPass']);
$name = empty($value['name'])?$value['user']:$value['name'];
//$categories[$key]['comment'] = " ";
- $videos[$key]['creator'] = '';
+ $videos[$key]['creator'] = '';
$videos[$key]['next_video'] = array();
$videos[$key]['description'] = ($videos[$key]['description']);
$videos[$key]['title'] = ($videos[$key]['title']);
$videos[$key]['typeLabels'] = Video::getVideoTypeLabels($videos[$key]['filename']);
if(!empty($videos[$key]['next_videos_id'])){
unset($_POST['searchPhrase']);
$videos[$key]['next_video'] = Video::getVideo($videos[$key]['next_videos_id']);
}
if($videos[$key]['type']=='article'){
$videos[$key]['videosURL'] = getVideosURLArticle($videos[$key]['filename']);
}else
if($videos[$key]['type']=='pdf'){
$videos[$key]['videosURL'] = getVideosURLPDF($videos[$key]['filename']);
}else if($videos[$key]['type']=='audio'){
$videos[$key]['videosURL'] = getVideosURLAudio($videos[$key]['filename']);
}else{
$videos[$key]['videosURL'] = getVideosURL($videos[$key]['filename']);
}
unset($videos[$key]['password']);
unset($videos[$key]['recoverPass']);
}
echo '{ "current": '.$_POST['current'].',"rowCount": '.$_POST['rowCount'].', "total": '.$total.', "rows":'. json_encode($videos).'}';
diff --git a/plugin/CustomizeUser/CustomizeUser.php b/plugin/CustomizeUser/CustomizeUser.php
index 7b06b7333..bd02bf80d 100644
--- a/plugin/CustomizeUser/CustomizeUser.php
+++ b/plugin/CustomizeUser/CustomizeUser.php
@@ -1,237 +1,239 @@
userCanAllowFilesDownload = false;
$obj->userCanAllowFilesShare = false;
$obj->userCanAllowFilesDownloadSelectPerVideo = false;
$obj->userCanAllowFilesShareSelectPerVideo = false;
$obj->usersCanCreateNewCategories = !isset($advancedCustom->usersCanCreateNewCategories) ? false : $advancedCustom->usersCanCreateNewCategories;
$obj->userCanNotChangeCategory = !isset($advancedCustom->userCanNotChangeCategory) ? false : $advancedCustom->userCanNotChangeCategory;
$obj->userMustBeLoggedIn = !isset($advancedCustom->userMustBeLoggedIn) ? false : $advancedCustom->userMustBeLoggedIn;
$obj->onlyVerifiedEmailCanUpload = !isset($advancedCustom->onlyVerifiedEmailCanUpload) ? false : $advancedCustom->onlyVerifiedEmailCanUpload;
$obj->sendVerificationMailAutomaic = !isset($advancedCustom->sendVerificationMailAutomaic) ? false : $advancedCustom->sendVerificationMailAutomaic;
$obj->unverifiedEmailsCanNOTLogin = !isset($advancedCustom->unverifiedEmailsCanNOTLogin) ? false : $advancedCustom->unverifiedEmailsCanNOTLogin;
$obj->newUsersCanStream = !isset($advancedCustom->newUsersCanStream) ? false : $advancedCustom->newUsersCanStream;
$obj->doNotIndentifyByEmail = !isset($advancedCustom->doNotIndentifyByEmail) ? false : $advancedCustom->doNotIndentifyByEmail;
$obj->doNotIndentifyByName = !isset($advancedCustom->doNotIndentifyByName) ? false : $advancedCustom->doNotIndentifyByName;
$obj->doNotIndentifyByUserName = !isset($advancedCustom->doNotIndentifyByUserName) ? false : $advancedCustom->doNotIndentifyByUserName;
$obj->hideRemoveChannelFromModeYoutube = !isset($advancedCustom->hideRemoveChannelFromModeYoutube) ? false : $advancedCustom->hideRemoveChannelFromModeYoutube;
$obj->showChannelBannerOnModeYoutube = !isset($advancedCustom->showChannelBannerOnModeYoutube) ? false : $advancedCustom->showChannelBannerOnModeYoutube;
$obj->encryptPasswordsWithSalt = !isset($advancedCustom->encryptPasswordsWithSalt) ? false : $advancedCustom->encryptPasswordsWithSalt;
$obj->requestCaptchaAfterLoginsAttempts = !isset($advancedCustom->requestCaptchaAfterLoginsAttempts) ? 0 : $advancedCustom->requestCaptchaAfterLoginsAttempts;
$obj->disableSignOutButton = false;
$obj->disableNativeSignUp = !isset($advancedCustom->disableNativeSignUp) ? false : $advancedCustom->disableNativeSignUp;
$obj->disableNativeSignIn = !isset($advancedCustom->disableNativeSignIn) ? false : $advancedCustom->disableNativeSignIn;
$obj->disablePersonalInfo = !isset($advancedCustom->disablePersonalInfo) ? true : $advancedCustom->disablePersonalInfo;
$obj->userCanChangeUsername = true;
$obj->signInOnRight = false;
$obj->doNotShowRightProfile = false;
$obj->doNotShowLeftProfile = false;
$obj->forceLoginToBeTheEmail = false;
// added on 2019-02-11
$o = new stdClass();
$o->type = "textarea";
$o->value = "";
$obj->messageToAppearBelowLoginBox = $o;
$obj->doNotShowTopBannerOnChannel = false;
$obj->doNotShowMyChannelNameOnBasicInfo = false;
$obj->doNotShowMyAnalyticsCodeOnBasicInfo = false;
$obj->doNotShowMyAboutOnBasicInfo = false;
$obj->MyChannelLabel = "My Channel";
$obj->afterLoginGoToMyChannel = false;
$obj->afterLogoffGoToMyChannel = false;
$obj->allowDonationLink = false;
+ $obj->showEmailVerifiedMark = true;
+
return $obj;
}
static function canDownloadVideosFromUser($users_id) {
global $config;
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesDownload)) {
return $config->getAllow_download();
}
$user = new User($users_id);
return !empty($user->getExternalOption('userCanAllowFilesDownload'));
}
static function setCanDownloadVideosFromUser($users_id, $value = true) {
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesDownload)) {
return false;
}
$user = new User($users_id);
return $user->addExternalOptions('userCanAllowFilesDownload', $value);
}
static function canShareVideosFromUser($users_id) {
global $advancedCustom;
if (!empty($advancedCustom->disableShareAndPlaylist)) {
return false;
}
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesShare)) {
return true;
}
$user = new User($users_id);
return !empty($user->getExternalOption('userCanAllowFilesShare'));
}
static function setCanShareVideosFromUser($users_id, $value = true) {
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesShare)) {
return false;
}
$user = new User($users_id);
return $user->addExternalOptions('userCanAllowFilesShare', $value);
}
static function getSwitchUserCanAllowFilesDownload($users_id) {
global $global;
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesDownload.php';
}
static function getSwitchUserCanAllowFilesShare($users_id) {
global $global;
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesShare.php';
}
public function getMyAccount($users_id) {
$objcu = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) {
echo '';
}
if (!empty($objcu) && !empty($objcu->userCanAllowFilesShare)) {
echo '';
}
}
public function getTags() {
return array('free', 'customization', 'users');
}
public function getChannelButton() {
global $global, $isMyChannel;
if (!$isMyChannel) {
return "";
}
$objcu = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
echo "";
if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) {
echo '
';
echo '
';
self::getSwitchUserCanAllowFilesDownload(User::getId());
echo '
' . __("Allow Download My Videos") . ' ';
}
if (!empty($objcu) && !empty($objcu->userCanAllowFilesShare)) {
echo '
';
echo '
';
self::getSwitchUserCanAllowFilesShare(User::getId());
echo '
' . __("Allow Share My Videos") . ' ';
}
echo "
";
}
public function getVideoManagerButton() {
global $isMyChannel;
$isMyChannel = true;
return self::getChannelButton();
}
static function canDownloadVideosFromVideo($videos_id) {
$video = new Video("", "", $videos_id);
if(empty($video)){
return false;
}
$users_id = $video->getUsers_id();
if(!self::canDownloadVideosFromUser($users_id)){
return false;
}
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) {
if(empty($video->getCan_download())){
return false;
}
}
return true;
}
static function canShareVideosFromVideo($videos_id) {
$video = new Video("", "", $videos_id);
if(empty($video)){
return false;
}
$users_id = $video->getUsers_id();
if(!self::canShareVideosFromUser($users_id)){
return false;
}
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (!empty($obj->userCanAllowFilesShareSelectPerVideo)) {
if(empty($video->getCan_share())){
return false;
}
}
return true;
}
public function onUserSignup($users_id) {
$obj = $this->getDataObject();
if ($obj->sendVerificationMailAutomaic) {
url_get_contents("{$global['webSiteRootURL']}objects/userVerifyEmail.php?users_id=$users_id");
}
}
public function getWatchActionButton($videos_id) {
global $global, $video;
$obj = $this->getDataObject();
include $global['systemRootPath'] . 'plugin/CustomizeUser/actionButton.php';
}
}
diff --git a/plugin/FBTube/view/getVideos.php b/plugin/FBTube/view/getVideos.php
index 9e59ab7a1..6dcc45da9 100644
--- a/plugin/FBTube/view/getVideos.php
+++ b/plugin/FBTube/view/getVideos.php
@@ -1,595 +1,595 @@
$value) {
$videos[$key] = Video::getVideo($value['id']);
$name = empty($value['name']) ? $value['user'] : $value['name'];
- $videos[$key]['creator'] = '';
+ $videos[$key]['creator'] = '';
}
$count = 0;
if (!empty($videos)) {
foreach ($videos as $video) {
$count++;
$img_portrait = ($video['rotation'] === "90" || $video['rotation'] === "270") ? "img-portrait" : "";
$playNowVideo = $video;
$transformation = "{rotate:" . $video['rotation'] . ", zoom: " . $video['zoom'] . "}";
if ($video['rotation'] === "90" || $video['rotation'] === "270") {
$aspectRatio = "9:16";
$vjsClass = "vjs-9-16";
$embedResponsiveClass = "embed-responsive-9by16";
} else {
$aspectRatio = "16:9";
$vjsClass = "vjs-16-9";
$embedResponsiveClass = "embed-responsive-16by9";
}
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio")) {
$poster = "{$global['webSiteRootURL']}videos/{$video['filename']}.jpg";
} else {
$poster = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
?>
label === __("Group")) {
?>
text; ?>
doNotDisplayViews)) {
?>
! .
diff --git a/plugin/Live/view/modeYoutubeLive.php b/plugin/Live/view/modeYoutubeLive.php
index c41088b35..b4528cb22 100644
--- a/plugin/Live/view/modeYoutubeLive.php
+++ b/plugin/Live/view/modeYoutubeLive.php
@@ -1,137 +1,137 @@
getBdId();
$subscribe = Subscribe::getButton($user_id);
$name = $u->getNameIdentificationBd();
-$name = "{$name} ";
+$name = "{$name} " . User::getEmailVerifiedIcon($user_id) . " ";
$video['creator'] = '';
$img = "{$global['webSiteRootURL']}plugin/Live/getImage.php?u={$_GET['u']}&format=jpg";
$imgw = 640;
$imgh = 360;
$liveDO = YouPHPTubePlugin::getObjectData("Live");
?>
- - getWebSiteTitle(); ?>
- getWebSiteTitle(); ?>" />
" />
userCanSeeTransmition()) {
?>
disableDVR)) {
?>
getChat($uuid);
}
?>
diff --git a/plugin/LiveLinks/view/Live.php b/plugin/LiveLinks/view/Live.php
index 6a30f83e8..14efb940e 100644
--- a/plugin/LiveLinks/view/Live.php
+++ b/plugin/LiveLinks/view/Live.php
@@ -1,123 +1,123 @@
getType()=='logged_only' && !User::isLogged()){
die('Link for logged only');
}
$uuid = $_GET['link'];
$t['users_id'] = $liveLink->getUsers_id();
$t['title'] = $liveLink->getTitle();
$t['link'] = $liveLink->getLink();
$t['description'] = $liveLink->getDescription();
$u = new User($t['users_id']);
$user_id = $u->getBdId();
$subscribe = Subscribe::getButton($user_id);
-$name = $u->getNameIdentificationBd();
+$name = $u->getNameIdentificationBd() .' '. User::getEmailVerifiedIcon($user_id);
$video['creator'] = '';
$img = "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?link={$_GET['link']}&format=jpg";
$imgw = 640;
$imgh = 360;
if(!empty($_GET['embed'])){
include $global['systemRootPath'].'plugin/LiveLinks/view/videoEmbeded.php';
return false;
}
?>
- - getWebSiteTitle(); ?>
- getWebSiteTitle(); ?>" />
" />
getChat($uuid);
}
?>
diff --git a/view/modeYoutube.php b/view/modeYoutube.php
index f7526783a..4b7243a1a 100644
--- a/view/modeYoutube.php
+++ b/view/modeYoutube.php
@@ -1,500 +1,500 @@
forceCategory) && $advancedCustom->forceCategory === false)) {
$_GET['catName'] = "";
}
if (empty($video)) {
$video = Video::getVideo("", "viewable", false, false, true, true);
}
if (empty($video)) {
$video = Video::getVideo("", "viewable", false, false, false, true);
}
if (empty($video)) {
$video = YouPHPTubePlugin::getVideo();
}
// allow users to count a view again in case it is refreshed
Video::unsetAddView($video['id']);
// add this because if you change the video category the video was not loading anymore
$_GET['catName'] = $catName;
$_GET['isMediaPlaySite'] = $video['id'];
$obj = new Video("", "", $video['id']);
/*
if (empty($_SESSION['type'])) {
$_SESSION['type'] = $video['type'];
}
*
*/
// $resp = $obj->addView();
$get = array('channelName' => @$_GET['channelName'], 'catName' => @$_GET['catName']);
if (!empty($_GET['playlist_id'])) {
$playlist_id = $_GET['playlist_id'];
if (!empty($_GET['playlist_index'])) {
$playlist_index = $_GET['playlist_index'];
} else {
$playlist_index = 0;
}
$videosArrayId = PlayList::getVideosIdFromPlaylist($_GET['playlist_id']);
$videosPlayList = Video::getAllVideos("viewable",false, false, $videosArrayId, false, true);
$videosPlayList = PlayList::sortVideos($videosPlayList, $videosArrayId);
$video = Video::getVideo($videosPlayList[$playlist_index]['id'], "viewable", false, false, false, true);
if (!empty($videosPlayList[$playlist_index + 1])) {
$autoPlayVideo = Video::getVideo($videosPlayList[$playlist_index + 1]['id'], "viewable", false, false, false, true);
$autoPlayVideo['url'] = $global['webSiteRootURL'] . "playlist/{$playlist_id}/" . ($playlist_index + 1);
} else if (!empty($videosPlayList[0])) {
$autoPlayVideo = Video::getVideo($videosPlayList[0]['id'], "viewable", false, false, false, true);
$autoPlayVideo['url'] = $global['webSiteRootURL'] . "playlist/{$playlist_id}/0";
}
unset($_GET['playlist_id']);
} else {
if (!empty($video['next_videos_id'])) {
$autoPlayVideo = Video::getVideo($video['next_videos_id']);
} else {
if ($video['category_order'] == 1) {
unset($_POST['sort']);
$category = Category::getAllCategories();
$_POST['sort']['title'] = "ASC";
// maybe there's a more slim method?
$videos = Video::getAllVideos();
$videoFound = false;
$autoPlayVideo;
foreach ($videos as $value) {
if ($videoFound) {
$autoPlayVideo = $value;
break;
}
if ($value['id'] == $video['id']) {
// if the video is found, make another round to have the next video properly.
$videoFound = true;
}
}
} else {
$autoPlayVideo = Video::getRandom($video['id']);
}
}
if (!empty($autoPlayVideo)) {
- $name2 = User::getNameIdentificationById($autoPlayVideo['users_id']);
+ $name2 = User::getNameIdentificationById($autoPlayVideo['users_id']).' '. User::getEmailVerifiedIcon($autoPlayVideo['users_id']);
$autoPlayVideo['creator'] = '';
$autoPlayVideo['tags'] = Video::getTags($autoPlayVideo['id']);
//$autoPlayVideo['url'] = $global['webSiteRootURL'] . $catLink . "video/" . $autoPlayVideo['clean_title'];
$autoPlayVideo['url'] = Video::getLink($autoPlayVideo['id'], $autoPlayVideo['clean_title'], false, $get);
}
}
if (!empty($video)) {
$name = User::getNameIdentificationById($video['users_id']);
- $name = "{$name} ";
+ $name = "{$name} " . User::getEmailVerifiedIcon($video['users_id'])." ";
$subscribe = Subscribe::getButton($video['users_id']);
$video['creator'] = '';
$obj = new Video("", "", $video['id']);
// dont need because have one embeded video on this page
// $resp = $obj->addView();
}
if ($video['type'] == "video") {
$poster = "{$global['webSiteRootURL']}videos/{$video['filename']}.jpg";
} else {
$poster = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
if (!empty($video)) {
$source = Video::getSourceFile($video['filename']);
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) {
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} else if ($video['type'] == "audio") {
$img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
$type = 'video';
if ($video['type'] === 'pdf') {
$type = 'pdf';
}
if ($video['type'] === 'article') {
$type = 'article';
}
$images = Video::getImageFromFilename($video['filename'], $type);
$poster = $images->poster;
if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') {
$img = $images->posterPortrait;
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} else {
$img = $images->poster;
}
} else {
$poster = "{$global['webSiteRootURL']}view/img/notfound.jpg";
}
$objSecure = YouPHPTubePlugin::getObjectDataIfEnabled('SecureVideosDirectory');
if (!empty($autoPlayVideo)) {
$autoPlaySources = getSources($autoPlayVideo['filename'], true);
$autoPlayURL = $autoPlayVideo['url'];
$autoPlayPoster = "{$global['webSiteRootURL']}videos/{$autoPlayVideo['filename']}.jpg";
$autoPlayThumbsSprit = "{$global['webSiteRootURL']}videos/{$autoPlayVideo['filename']}_thumbsSprit.jpg";
} else {
$autoPlaySources = array();
$autoPlayURL = '';
$autoPlayPoster = '';
$autoPlayThumbsSprit = "";
}
if (empty($_GET['videoName'])) {
$_GET['videoName'] = $video['clean_title'];
}
$v = Video::getVideoFromCleanTitle($_GET['videoName']);
YouPHPTubePlugin::getModeYouTube($v['id']);
?>
- getWebSiteTitle(); ?>
showChannelBannerOnModeYoutube)) {
?>
! videoNotFoundText->value) ? __("We have not found any videos or audios to show") : $advancedCustom->videoNotFoundText->value; ?>.
disableYoutubePlayerIntegration;
} else {
$disableYoutubeIntegration = false;
}
if ((isset($_GET['isEmbedded'])) && ($disableYoutubeIntegration == false)) {
if ($_GET['isEmbedded'] == "y") {
$videoJSArray[] = "view/js/videojs-youtube/Youtube.js";
} else if ($_GET['isEmbedded'] == "v") {
$videoJSArray[] = "view/js/videojs-vimeo/videojs-vimeo.js";
}
}
$jsURL = combineFiles($videoJSArray, "js");
?>
diff --git a/view/modeYoutubeBottom.php b/view/modeYoutubeBottom.php
index c4a289b34..30fd9dd80 100644
--- a/view/modeYoutubeBottom.php
+++ b/view/modeYoutubeBottom.php
@@ -1,396 +1,396 @@
{$name}";
+ $name = "{$name} " . User::getEmailVerifiedIcon($video['users_id']) . " ";
$subscribe = Subscribe::getButton($video['users_id']);
$video['creator'] = '';
$source = Video::getSourceFile($video['filename']);
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) {
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} else if ($video['type'] == "audio") {
$img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
$type = 'video';
if ($video['type'] === 'pdf') {
$type = 'pdf';
}
$images = Video::getImageFromFilename($video['filename'], $type);
$poster = $images->poster;
if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') {
$img = $images->posterPortrait;
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
}
}
?>
" class="img img-responsive rotate" height="130" itemprop="thumbnail" />
- " />
">
label === __("Group")) {
?>
text; ?>
doNotDisplayViews)) {
?>
:
:
:
disableHTMLDescription)?$video['description']:nl2br(textToLink(htmlentities($video['description']))); ?>
\ No newline at end of file
diff --git a/view/videosList.php b/view/videosList.php
index d8beced0a..6865a0cbb 100644
--- a/view/videosList.php
+++ b/view/videosList.php
@@ -1,306 +1,306 @@
@$_GET['channelName'], 'catName' => @$_GET['catName']);
if (!empty($_GET['channelName']) && empty($advancedCustomUser->hideRemoveChannelFromModeYoutube)) {
$user = User::getChannelOwner($_GET['channelName']);
//var_dump($user);exit;
?>
>
>
>
>
>
doNotDisplayViews)) {
?>
>
>10
>20
>30
>40
>50
$value) {
if (!empty($video['id']) && $video['id'] == $value['id']) {
continue; // skip video
}
- $name = User::getNameIdentificationById($value['users_id']);
+ $name = User::getNameIdentificationById($value['users_id']).' '. User::getEmailVerifiedIcon($value['users_id']);
$value['creator'] = '';
?>
\ No newline at end of file